package com.ruoyi.factory.buyprice.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.factory.buyprice.domain.BurateMonth;
import com.ruoyi.factory.buyprice.service.IBurateMonthService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 采购行情月汇率Controller
 * 
 * @author ruoyi
 * @date 2024-05-29
 */
@RestController
@RequestMapping("/system/month")
public class BurateMonthController extends BaseController
{
    @Autowired
    private IBurateMonthService burateMonthService;

    /**
     * 查询采购行情月汇率列表
     */
    @PreAuthorize("@ss.hasPermi('system:month:list')")
    @GetMapping("/list")
    public TableDataInfo list(BurateMonth burateMonth)
    {
        startPage();
        List<BurateMonth> list = burateMonthService.selectBurateMonthList(burateMonth);
        return getDataTable(list);
    }

    /**
     * 导出采购行情月汇率列表
     */
    @PreAuthorize("@ss.hasPermi('system:month:export')")
    @Log(title = "采购行情月汇率", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BurateMonth burateMonth)
    {
        List<BurateMonth> list = burateMonthService.selectBurateMonthList(burateMonth);
        ExcelUtil<BurateMonth> util = new ExcelUtil<BurateMonth>(BurateMonth.class);
        util.exportExcel(response, list, "采购行情月汇率数据");
    }

    /**
     * 获取采购行情月汇率详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:month:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(burateMonthService.selectBurateMonthById(id));
    }

    /**
     * 新增采购行情月汇率
     */
    @PreAuthorize("@ss.hasPermi('system:month:add')")
    @Log(title = "采购行情月汇率", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BurateMonth burateMonth)
    {
        return toAjax(burateMonthService.insertBurateMonth(burateMonth));
    }

    /**
     * 修改采购行情月汇率
     */
    @PreAuthorize("@ss.hasPermi('system:month:edit')")
    @Log(title = "采购行情月汇率", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BurateMonth burateMonth)
    {
        return toAjax(burateMonthService.updateBurateMonth(burateMonth));
    }

    /**
     * 删除采购行情月汇率
     */
    @PreAuthorize("@ss.hasPermi('system:month:remove')")
    @Log(title = "采购行情月汇率", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(burateMonthService.deleteBurateMonthByIds(ids));
    }
}
